package cn.snowsoft.iot.module.warning.service.warning.record;

import cn.snowsoft.iot.module.warning.controller.admin.warning.record.vo.WarningRecordDetailReqVO;
import cn.snowsoft.iot.module.warning.dal.dataobject.warning.record.OutPutRecord;
import cn.snowsoft.iot.module.warning.dal.dataobject.warning.record.WarningRecordDO;
import cn.snowsoft.iot.module.warning.dal.mysql.warning.record.OutPutRecordMapper;
import cn.snowsoft.iot.module.warning.dal.mysql.warning.record.WarningRecordMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IOutPutRecordServiceImpl extends ServiceImpl<OutPutRecordMapper, OutPutRecord> implements IOutPutRecordService{



    @Override
    public List<OutPutRecord> getOutPutRecodeDetailList(WarningRecordDetailReqVO warningRecordDetailReqVO) {
        LambdaQueryWrapper<OutPutRecord> lambdaQuery =  new LambdaQueryWrapper<>();

        if (StringUtils.isNotEmpty(warningRecordDetailReqVO.getWarningTag())){
            lambdaQuery.eq(OutPutRecord::getWarningRecordId, warningRecordDetailReqVO.getWarningTag());

        }
        if (StringUtils.isNotEmpty(warningRecordDetailReqVO.getActionType())){
            lambdaQuery.eq(OutPutRecord::getActionType, warningRecordDetailReqVO.getActionType());

        }
        List<OutPutRecord> outPutRecord = baseMapper.selectList(lambdaQuery);
        return outPutRecord;
    }

    @Override
    public void saveOutPutRecord(OutPutRecord outPutRecord) {
        baseMapper.insert(outPutRecord);
    }
}
